package com.framework.web.bus.service;
import com.framework.web.bus.domain.OrderItemInfo;
import com.framework.web.bus.repository.OrderItemInfoRepository;
import com.framework.web.bus.repository.specifications.OrderItemInfoSpecs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @Title: Service
* @Description: 业务层
* @author zqtao
* @date 2016-09-11
* @version V1.0
*
*/
@Service
public class OrderItemInfoService {

@Autowired
private OrderItemInfoRepository  orderItemInfoRepository;

/**
* 新增或者保存
* @param orderItemInfo
* @return
*/
public OrderItemInfo save(OrderItemInfo orderItemInfo) {
    return orderItemInfoRepository.save(orderItemInfo);
}

/**
* 删除
* @param id
*/
public void  delete(String id) {
    orderItemInfoRepository.delete(id);
}
/**
* 根据id查询
* @param id
* @return
*/
public OrderItemInfo findById(String id) {
    return orderItemInfoRepository.findOne(id);
}


/**
* 分页查找
* @param orderItemInfo
* @param pr
* @return
*/
public Page<OrderItemInfo> getPageList(OrderItemInfo orderItemInfo, PageRequest pr) {
    Page<OrderItemInfo> totalList = orderItemInfoRepository.findAll(OrderItemInfoSpecs.pageQueryOrderItemInfo(orderItemInfo), pr);
    return totalList;
}

    /**
     * 订单详情查询
     * @param orderId
     * @return
     */
public List<OrderItemInfo> findByOrderId(String orderId){
    return orderItemInfoRepository.findByOrderId(orderId);
}

}
